import backtrader as bt


def single_symbol_spot_backtest(
        dataframe, strategy, strategy_args, 
        init_cash=10000, commission=0.001, plot=False):
    # 创建Cerebro引擎
    cerebro = bt.Cerebro()

    # 添加数据到Cerebro引擎
    cerebro.adddata(bt.feeds.PandasData(dataname=dataframe))

    # 添加策略到Cerebro引擎
    cerebro.addstrategy(strategy, **strategy_args)

    # 设置初始现金和手续费
    cerebro.broker.setcash(init_cash)
    cerebro.broker.setcommission(commission=commission)

    # 运行策略
    init_value = cerebro.broker.getvalue()
    cerebro.run()
    profit = (cerebro.broker.getvalue() - init_value) / init_value

    # 可视化
    if plot:
        cerebro.plot(style='candlestick', iplot=False)

    return profit, cerebro
